home *** CD-ROM | disk | FTP | other *** search
/ The Grapevine 12 / Grapevine_12_1994-10-25_TDR_Side_A.d64 / ass.irq ldr 0.7 next >
Text File  |  2023-02-26  |  7KB  |  290 lines

  1. ;--- WHIPLOADER IRQ 0.7 ---
  2.  
  3. ciout    = $ffa8  ;Output byte to ser.
  4. listen   = $ffb1
  5. second   = $ff93
  6. unlsn    = $ffae
  7.  
  8.  
  9.          *= $c000
  10.  
  11.          ldx #<load   ;Set LOAD vector.
  12.          ldy #>load
  13.          stx $0330
  14.          sty $0331
  15.          rts
  16.  
  17. command  ;Initialize for talking
  18.          lda $ba    ;Device#
  19.          jsr listen
  20.          lda #$6f   ;Sec addr
  21.          jsr second
  22.          lda #$4d   ;"M"
  23.          jsr ciout
  24.          lda #$2d   ;"-"
  25.          jsr ciout
  26.          txa        ;"x"
  27.          jsr ciout
  28.          tya        ;"y"
  29.          jmp ciout
  30.  
  31. load     ;Actual LOAD.
  32.          stx $ae
  33.          sty $af
  34.          sta $93
  35.          tay         ;Check if
  36.          beq notver  ; LOAD or VERIFY.
  37. normal   jmp $f4a7   ;Normal LOAD.
  38. notver   sty $d015   ;Sprites off.
  39.          lda ($bb),y
  40.          cmp #$24
  41.          beq normal
  42.  
  43.          jsr drvwait
  44.          lda $ba
  45.          jsr listen
  46.          lda #$f0
  47.          jsr second
  48.          ldy #0
  49. nameloop lda ($bb),y
  50.          jsr ciout
  51.          iny
  52.          cpy $b7
  53.          bcc nameloop
  54.          jsr unlsn
  55.  
  56.          jsr drvwait
  57.  
  58.          ldy #$00    ;Lo address
  59. writer   ldx #$57    ;"W"rite
  60.          jsr command       ;of drive mem
  61.          lda #$05    ;Hi address
  62.          jsr ciout   ;(ie. $0500)
  63.          lda #$1c    ;28 bytes
  64.          jsr ciout
  65.          tax            ;Y-reg used as
  66. writelp  lda drvcode,y  ; index and 'lo'
  67.          jsr ciout      ; byte.
  68.          iny
  69.          dex
  70.          bne writelp
  71.          jsr unlsn
  72.          cpy #$d0    ;Do until all bytes
  73.          bcc writer  ; written to drive.
  74.  
  75.          ldx #$45    ;"E"xecute
  76.          ldy #<drvinit-drvcode
  77.          jsr command
  78.          lda #$05    ;hi (ie. JMP $05xx)
  79.          jsr ciout
  80.          jsr unlsn
  81.  
  82.          lda $dd00
  83.          and #$07    ;Save $DD00 value.
  84.          sta savedd00+1
  85.          tax
  86.          ora #$10
  87.          sta $dd00
  88.          lda andbyte,x
  89.          sta adjdd00+1  ;Used to adjust
  90.              ; byte just received 'cos
  91.              ; of variable $DD00 value.
  92.          ldy #drvcode-locode
  93.              ;Size of low code.
  94. locodemv lda locode-1,y
  95.          sta $0100-1,y
  96.          dey
  97.          bne locodemv
  98.          jsr $0100
  99.          pha
  100.          jsr $0100   ;Get load address
  101.          pha         ; & sect. pointer.
  102.          jsr $0100
  103.          tay
  104.          jsr $0100
  105.          ldx $b9     ;Secondary addrs.
  106.          beq comma0
  107.          sty $ae
  108.          sta $af
  109. comma0   sty $c3   ;Address where prog
  110.          sta $c4   ; was saved.
  111.          pla
  112.          tax   ;Prepare X-reg in case
  113.          dex   ; first block is last.
  114.          dex
  115.          pla
  116.          jmp loading-locode+$0100
  117.              ;Adjust for low memory.
  118.  
  119. drvwait  ;Wait for drive to be ready.
  120.          lda $dd00
  121.          and #$07
  122.          ora #$08
  123.          sta $dd00
  124.          tax
  125. waitloop lda $dd00
  126.          bpl waitloop
  127.          txa
  128.          and #$07
  129.          sta $dd00
  130.          rts
  131.  
  132. andbyte  .byte $ff,$fe,$fd,$fc
  133.          .byte $fa,$fb,$f8,$f9
  134.  
  135.  
  136. ;---------------------------------------
  137.  
  138. locode   ;Code works at $0100!
  139.  
  140.     ;Get a byte.
  141.          lda $dd00  ;Wait until drive
  142.          bpl locode ; is ready.
  143.          sei        ;Interrupts off!!!!
  144. savedd00 ldx #0     ;Prep register...
  145. rastwait lda $d012
  146.          cmp #$31
  147.          bcc lineok ;In top/bot border.
  148.          and #$06   ;Ensure raster pos
  149.          cmp #$02   ; doesn't inerfere.
  150.          beq rastwait
  151. lineok   stx $dd00  ;Ready for transfer.
  152.          txa
  153.          ora #$10   ;Prep register...
  154.          tax
  155.          lda $02a6  ;Pause for NTSC/PAL
  156.          beq here   ; compatibility. [?]
  157. here     nop
  158.          lda $dd00  ;Transfer byte Two
  159.          lsr a      ; bits at a time.
  160.          lsr a
  161.          eor $dd00
  162.          lsr a
  163.          lsr a
  164.          eor $dd00
  165.          lsr a
  166.          lsr a
  167.          eor $dd00
  168. adjdd00  eor #0
  169.          stx $dd00  ;Set 'wait'
  170.          cli
  171.          rts
  172.  
  173. getblock
  174.          sta $63     ;Save #bytes.
  175.          ldy #$00
  176. blocklp  jsr $0100
  177.          sta ($ae),y ; and store byte.
  178.          iny
  179.          cpy $63 ;Check if all bytes
  180.                  ; of sector transfered.
  181.          bne blocklp
  182.          tya
  183.          clc
  184.          adc $ae    ;Increase Pointer.
  185.          sta $ae
  186.          bcc noinc
  187.          inc $af
  188. noinc    rts
  189.  
  190. loading
  191.          beq loadlast
  192.          lda #$fc
  193.          .byte $2c ;BIT
  194. loadloop lda #$fe
  195.          jsr getblock-locode+$0100
  196.          jsr $0100
  197.          pha       ;Get next Track and
  198.          jsr $0100 ; Sector values.
  199.          tax       ;X-reg hold number
  200.          pla       ; of bytes if last.
  201.          bne loadloop
  202. loadlast dex
  203.          txa
  204.          jsr getblock-locode+$0100
  205.          jmp $f528 ;End load incl fix.
  206.  
  207. ;---------------------------------------
  208.  
  209. drvcode  ;Code moved into disk drive
  210.          ; from $0500
  211.          lda #$03    ;Page where data
  212.          sta $31     ; is read into.
  213. drvmainl jsr $0150   ;Transfered ROM.
  214.          ldy #$00
  215. drvloop  ldx $0300,y
  216.          lda $0600,x   ;Get high nybble.
  217.          sta hisave-drvcode+$0501
  218.          txa
  219.          ldx #$00      ;Drive is ready.
  220.          stx $1800
  221.          and #$0f
  222.          tax
  223.          lda #$04;Wait until bit $04
  224. drvwait1 bit $1800  ; is set by computer
  225.          bne drvwait1
  226.          lda sendbyte-drvcode+$0500,x
  227.          sta $1800
  228.          asl a
  229.          and #$0f
  230.          sta $1800
  231.          nop
  232. hisave   lda #0    ;Recall hi byte val.
  233.          sta $1800
  234.          asl a
  235.          and #$0f
  236.          sta $1800
  237.          lda #$02
  238.          iny
  239.          sta $1800   ;Restore serial bus
  240.          bne drvloop
  241.          lda $0301   ;Set Sector
  242.          sta $0b
  243.          sta $81
  244.          lda $0300
  245.          cmp $0a      ;Keep going if
  246.          beq drvmainl ; same track.
  247.          sta $80
  248.          jmp $f418    ;Next Track
  249.  
  250. sendbyte .byte 0,8,2,10,4,12,6,14
  251.          .byte 1,9,3,11,5,13,7,15
  252.  
  253. drvinit  ldy #$02
  254.          sty $1800
  255.          ldx #$00
  256. drvhilp  txa
  257.          lsr a     ;Prepare high byte
  258.          lsr a     ; values for better
  259.          lsr a     ; speed.
  260.          lsr a
  261.          tay
  262.          lda sendbyte-drvcode+$0500,y
  263.          sta $0600,x
  264.          inx
  265.          bne drvhilp
  266.          ldx #$39
  267. drvromc  lda $f4d0,x  ;Copy drive ROM.
  268.          sta $014f,x
  269.          dex
  270.          bne drvromc
  271.          lda #$60     ;'RTS'
  272.          sta $0184
  273.          lda $19      ;First trck & sect
  274.          sta $0b      ; copy to used one
  275.          lda $18
  276. drvloop2 sta $0a
  277.          ldx #$02
  278.          stx $f9
  279.          lda #$e0
  280.          jsr $d57d
  281.          dec $0298
  282.          jsr $d599
  283.          cmp #$02
  284.          bcs drverr
  285.          lda $80
  286.          bne drvloop2
  287.          jmp $c194
  288. drverr   jmp $e60a
  289.  
  290.